package com.xju.boot_23_24.controller;

import com.xju.boot_23_24.entity.Book;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@Controller
public class UserController {

    @RequestMapping("/index")
    public String html(Model model) {
        Book book = new Book();
        book.setBookName("三国演义");
        book.setPrice(88.8);
        Book book1 = new Book();
        book1.setPrice(77.7);
        book1.setBookName("西游记");
        model.addAttribute("price", 99.9);
        model.addAttribute("str", "书名");
        model.addAttribute("book", book);
        model.addAttribute("color", "red");
        List<Book> books = new ArrayList<>();
        books.add(book);
        books.add(book1);
        model.addAttribute("books", books);
        return "index";
    }
}
